﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business.OnlineService;
 

namespace Eis51.CampanyCMS.UI.Admin.SystemManager
{
    public partial class MakeXml : System.Web.UI.Page
    {
        public string strALL = "";
        public string AllMenu = "";
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string top = @"<Menus ID =""{0}"" Text=""{1}"" NavigateUrl=""{3}"">
                            {2}
                           </Menus>";

            string Send = @"   <MenuItem ID =""{0}"" Text=""{1}"" NavigateUrl=""~/admin/NewsManager/NewsList.aspx?licd=2052&amp;Typecode={2}""></MenuItem> ";
           

            string menuTop=@" 
                            mpmenu = new mMenu('<span style=""color:#ffffff;"">|&nbsp;</span>{0} ','NEWSTOP{1}.html','self','','','','');";
            string menuSend = @" 
                            mpmenu.addItem(new mMenuItem('&nbsp;- <span style=""line-height: 20px;"">{0}','NEWSLIST{1}_1.html','self',false,'{0}','','','',''));";


            string sql = "select * from NewsType where parentid=0 order by createdate asc   ";
            DataTable dt =BaseChatToolsBLL.GetInstance().GetDataTable(sql);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string str = "";
                sql = string.Format("select * from  NewsType where parentid={0}", dt.Rows[i]["NEWSTYPEID"].ToString());
                AllMenu += string.Format(menuTop, dt.Rows[i]["NewsTypeName"].ToString(), dt.Rows[i]["Code"].ToString());

                DataTable temp = BaseChatToolsBLL.GetInstance().GetDataTable(sql);
                for (int j = 0; j < temp.Rows.Count; j++)
                {
                    AllMenu += string.Format(menuSend, temp.Rows[j]["NewsTypeName"].ToString(), temp.Rows[j]["Code"].ToString());

                    str += string.Format(Send,(i + 4).ToString()+ (j + 1).ToString(), temp.Rows[j]["NewsTypeName"].ToString(), temp.Rows[j]["Code"].ToString());
                }

                string topUrl = string.Format("~/admin/NewsManager/NewsList.aspx?licd=2052&amp;Typecode={0}", dt.Rows[i]["Code"].ToString());                
                if (str != string.Empty)
                    topUrl = string.Empty;
                strALL += string.Format(top, i + 4, dt.Rows[i]["NewsTypeName"].ToString(), str, topUrl);
            
            }
        }
    }
}
